package com.harmontronics.hanma.paas.paas.service;

import com.harmontronics.hanma.paas.paas.consts.EnvEnum;
import com.harmontronics.hanma.paas.paas.consts.NumberEnum;
import com.harmontronics.hanma.paas.paas.domain.releasesetup.service.HmReleaseSetupService;
import com.harmontronics.hanma.paas.paas.domain.tenant.entity.HmTenantApp;
import com.harmontronics.hanma.paas.paas.domain.tenant.service.HmTenantAppService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Service("hmTenantAppExtService")
@ConditionalOnProperty(prefix = "mos.oss",name="enabled",havingValue = "false")
public class HmTenantAppExtService extends HmTenantAppService implements IHmTenantAppService{

    @Autowired
    private HmReleaseSetupService hmReleaseSetupService;
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void save(HmTenantApp hmTenantApp, String token) {
        super.save(hmTenantApp, token);
        hmReleaseSetupService.addDefault(hmTenantApp.getAppUniqueId(), EnvEnum.DEV);
        hmReleaseSetupService.addDefault(hmTenantApp.getAppUniqueId(), EnvEnum.TEST);
        hmReleaseSetupService.addDefault(hmTenantApp.getAppUniqueId(), EnvEnum.PROD);
    }
}